﻿package net.wangit.framework.util;

import java.util.List;
/**
 * JavaScript工具类
 * 
 * @author watson
 * Feb 14, 2010
 */
public class ScriptUtil {

	public ScriptUtil() {
	}

	public static final String getActionScript(List<String> scripts) {
		StringBuffer html = new StringBuffer("<script language=\"JavaScript\">");
		for (int i = 0; i < scripts.size(); i++){
			html.append(getScript(scripts.get(i))).append(";");
		}
		html.append("</script>");
		return html.toString();
	}

	private static final String getScript(String script) {
		script = script.replaceAll("\"", "\\\"");
		script = script.replaceAll("\n", "\\\n");
		return script;
	}
}
